package com.wmwj.hxlj.controller;

import com.wmwj.hxlj.entity.History;
import com.wmwj.hxlj.entity.vo.ArticleVo;
import com.wmwj.hxlj.entity.vo.PageResult;
import com.wmwj.hxlj.service.HistoryService;
import com.wmwj.hxlj.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    // 添加浏览记录
    @PostMapping("/add")
    public Result<String> addHistory(@RequestBody History history) {
        return historyService.addHistory(history);
    }

    // 获取用户的浏览记录
    @GetMapping("/user")
    public Result<PageResult<ArticleVo>> getHistoryByUserId(@RequestParam Long userId, @RequestParam Integer pageStart) {
        return historyService.getHistoryByUserId(userId, pageStart);
    }

    // 删除指定的浏览记录
    @DeleteMapping("/delete")
    public Result<String> deleteHistory(@RequestParam Long id) {
        return historyService.deleteHistory(id);
    }
}

